//贷款记录接口
;//type1贷款  amount
//type2还款  returnAmount
var str="";
var token = localStorage.getItem('tok');
$.ajax({
    type: "GET",
    url: $host+'/api/app/loan/loanRecord',
    data: {
        token:token,
        page:1,
        rows:5
    },
    async: true,
    dataType:'json',
    success: function(result){
        var data=result.data;
        for(let i=0;i<data.length;i++){
            var borrowTime=new Date(data[i].borrowTime).toLocaleString();
            var amount=data[i].amount;//贷款金额
            var returnAmount=data[i].returnAmount;//还款金额
            if(data[i].type===1) {
                str+=`<div class="layer">
                    <img src="../images/moneyicon@2x.png" alt="" class="l"/>
                    <div class="info l">
                        <a href="daikuanxq.html"><img src="../images/right_icon@2x.png" alt="" class="r"/></a>
                        <p class="r">${amount}元</p>
                        <div>贷款金额</div>
                        <span class="">${borrowTime}</span>
                    </div>
                </div>`
            }else{
                str+=`<div class="layer">
                    <img src="../images/moneyicon@2x.png" alt="" class="l"/>
                    <div class="info l">
                        <a href="daikuanxq.html"><img src="../images/right_icon@2x.png" alt="" class="r"/></a>
                        <p class="r">${amount}元</p>
                        <div>贷款金额</div>
                        <span class="">${borrowTime}</span>
                    </div>
                </div>
                 <div class="layer">
                    <img src="../images/moneyicon@2x.png" alt="" class="l"/>
                    <div class="info l">
                        <a href="daikuanxq.html"><img src="../images/right_icon@2x.png" alt="" class="r"/></a>
                        <p class="r active">${returnAmount}元</p>
                        <div>还款金额</div>
                        <span class="">${borrowTime}</span>
                    </div>
                </div>`
            }
        }
        $(".box").html(str)
    },
    error:function(){
        console.log('贷款记录接口错误')
    }
});
//点击返回
$('.dkjlfh').click(function(){
    window.location.href="gerenzx.html?token="+token;
})